Skip to content

fix(storage): send routing token once and use redirect write handle on append reconnect - #19205

Open
Yonghui-Lee wants to merge 1 commit into
googleapis:mainfrom
Yonghui-Lee:fix/storage-aaow-redirect-reopen
Open

Yonghui-Lee wants to merge 1 commit into
googleapis:mainfrom
Yonghui-Lee:fix/storage-aaow-redirect-reopen

Conversation

@Yonghui-Lee

Copy link
Copy Markdown

When AsyncAppendableObjectWriter.append() gets a BidiWriteObjectRedirectedError, it reconnects with the wrong request. This was found in review of #19092 (thanks @zhixiangli).

Problem

  • The append retry path adds x-goog-request-params: routing_token=... to the metadata and then calls open(), which adds the same header again. The stream joins all x-goog-request-params values, so the reopen carries routing_token twice. GCS rejects it with 400 InvalidArgument (GRPC_INVALID_X_GOOG_REQUEST_PARAMS_DUPLICATE_ENTRY), and the append fails after a redirect.
  • The write_handle from the redirect is saved in the retry state but never copied to self.write_handle, so the reopen uses the old handle.

Changes

  • Stop adding the routing token header in the append retry path. open() already adds it from self._routing_token.
  • Copy write_state.write_handle from the redirect to self.write_handle before reopening.
  • Add a unit test that injects a redirect during append() and checks that the reopen uses the redirect's write handle and token, sends the routing token header once, and keeps caller metadata.

Testing

  • Unit tests: tests/unit/asyncio/retry/test_writes_resumption_strategy.py and tests/unit/asyncio/test_async_appendable_object_writer.py pass. The new test fails without the fix.
  • Real zonal bucket: injected a redirect at 2 MiB during a 4 MiB append. On main the reopen fails with the duplicate entry error and only 2 MiB is stored. With this change the append completes and the object checksum matches.

Note: main currently has the storage rollback from #19186. This change is small and may need a rebase when those commits are restored.

@Yonghui-Lee
Yonghui-Lee requested review from a team as code owners November 25, 2026 08:55
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant